package com.fz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fz.entity.Collect;
import com.fz.service.CollectService;
import com.fz.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 存储收藏的商品信息 前端控制器
 * </p>
 *
 * @author hyr
 * @since 2025-06-18
 */
@RestController
@RequestMapping("/collect")
public class CollectController {
    @Resource
    private CollectService collectService;
    @PostMapping("/add")
    public ResultVo<Boolean> add(Long userId, Long goodsId) {
        return ResultVo.success(collectService.add(userId, goodsId));
    }
    @PostMapping("/search")
    public ResultVo<Boolean> search(Long userId, Long goodsId) {
        return ResultVo.success(collectService.search(userId, goodsId));
    }

    @PostMapping("/list")
    public ResultVo<IPage<Collect>> list(Long userId, Integer pageNo, Integer pageSize, Long selectedCategory) {
        return ResultVo.success(collectService.list(userId, pageNo, pageSize,selectedCategory));
    }

    @PostMapping("/delete")
    public ResultVo<Boolean> delete(Long userId, Long goodsId) {
        return ResultVo.success(collectService.delete(userId, goodsId));
    }
}
